/* eslint-disable */
/* tslint:disable */
// @ts-nocheck
/*
 * ---------------------------------------------------------------
 * ## THIS FILE WAS GENERATED VIA SWAGGER-TYPESCRIPT-API        ##
 * ##                                                           ##
 * ## AUTHOR: acacode                                           ##
 * ## SOURCE: https://github.com/acacode/swagger-typescript-api ##
 * ---------------------------------------------------------------
 */

export interface VideoSessionInit {
  /** 视频观看会话ID */
  sessionId: string;
  /** 报告key */
  reportKey?: string;
  /** 该视频是否有奖励 */
  hasReward: boolean;
  /** 观看进度阶段区间定义 */
  stageRanges?: VideoSessionInitStageRangesInner[];
}

export interface VideoSessionInitResponse {
  success?: boolean;
  code?: string;
  message?: string;
  obj?: VideoSessionInit;
}

/** 观看进度阶段区间定义 */
export interface VideoSessionInitStageRangesInner {
  /**
   * 阶段级别，例如：1, 2, 3
   * @format int32
   */
  level?: number;
  /** 阶段名称，例如：第一阶段 */
  name?: string;
  /**
   * 最小比例值
   * @format double
   */
  minRatio?: number;
  /**
   * 最大比例值
   * @format double
   */
  maxRatio?: number;
  /** 奖励值 */
  rewardAmount?: string;
}

export interface VideoSessionInitRequest {
  /** 视频标识符 */
  videoId: string;
  /** 平台，例如YouTube */
  platform: string;
}

/** 事件列表 */
export interface EventData {
  /** 事件类型 */
  eventType?: string;
  /**
   * 事件时间戳
   * @format int64
   */
  timestamp?: number;
  /**
   * 事件序号
   * @format int32
   */
  sequence?: number;
  details?: EventDataDetails;
}

export type EventDataDetails = object;

export interface VideoEventsReportRequest {
  /** 会话ID */
  sessionId: string;
  /** 用户ID */
  customerId: string;
  /** 数据签名 */
  signature: string;
  /**
   * 客户端时间戳
   * @format int64
   */
  clientTimestamp: number;
  /** 社交平台 */
  socialPlatform?: "X" | "YouTube";
  /** 社交事件 */
  socialEvent?: "replay" | "watch";
  /** 事件列表 */
  events: EventData[];
  /** 设备指纹 */
  deviceFinger?: string;
  /** 客户端IP */
  clientIp?: string;
}

export interface TaskVerify {
  /** 任务积分 */
  point?: string;
}

export interface TaskVerifyResponse {
  success?: boolean;
  code?: string;
  message?: string;
  obj?: TaskVerify;
}

export interface TaskVerifyRequest {
  /** 任务id */
  taskId: string;
}

export interface TaskSocialEventResponse {
  success?: boolean;
  code?: string;
  message?: string;
  obj?: TaskSocialEventVO;
}

export interface TaskSocialEventVO {
  /** 奖励的等级，普通金或者金蛋 */
  rexyRewardLevel?: string;
  /** 奖励ID，收集蛋的时候需要上送 */
  rexyRewardId?: string;
  /**
   * 奖励的积分
   * @format int64
   */
  rexyRewardPoint?: number;
}

export interface TaskSocialEventRequest {
  /** 平台，例如X */
  platform: "X";
  /** 行为，例如replay */
  type: "replay";
  /** 回复内容 */
  replyContent?: string;
  signature?: string;
  /** 社交内容ID */
  socialContentId?: string;
  /** @format int64 */
  time: number;
  /** 设备指纹 */
  deviceFinger?: string;
}

export interface ExtraRewardInfo {
  rexyRewardId?: string;
  rexyRewardPoint?: string;
}

export interface RewardCollect {
  rexyRewardLevel?: string;
  rexyRewardId?: string;
  rexyRewardPoint?: string;
  extraRewards?: ExtraRewardInfo[];
}

export interface RewardCollectResponse {
  success?: boolean;
  code?: string;
  message?: string;
  obj?: RewardCollect;
}

export interface RexyRewardCollectRequest {
  /** 奖励ID */
  rewardId?: string;
}

export interface ClaimResponse {
  success?: boolean;
  code?: string;
  message?: string;
  obj?: ClaimResponseAllOfObj;
}

export interface ClaimResponseAllOfObj {
  /** 金额 */
  amount?: string;
}

export interface RexyClaimRequest {
  /** 交易哈希 */
  transactionHash?: string;
  /** 调用数据 */
  callData?: string;
}

export interface ClaimBuildResponse {
  success?: boolean;
  code?: string;
  message?: string;
  obj?: ClaimBuildResponseAllOfObj;
}

export interface ClaimBuildResponseAllOfObj {
  /** 目标地址 */
  targetAddress?: string;
  /** 调用数据 */
  callData?: string;
  /** 金额 */
  amount?: string;
}

export interface BindWalletResponse {
  success?: boolean;
  code?: string;
  message?: string;
}

export interface SetHandleNameResponse {
  success?: boolean;
  code?: string;
  message?: string;
}

export interface SocialUploadResponse {
  success?: boolean;
  code?: string;
  message?: string;
}

export interface SocialUploadRequest {
  /** 拦截的url */
  url: string;
  /** url body */
  body: string;
}

export interface ReservePrivacyAuthResponse {
  success?: boolean;
  code?: string;
  message?: string;
  /** 执行结果 */
  obj?: boolean;
}

export interface ReversePrivacyAuth {
  /** 授权平台 X or YouTube */
  platform?: string;
}

export interface InviteBindResponse {
  success?: boolean;
  code?: string;
  message?: string;
}

export interface InviteBindRequest {
  /** 邀请码 */
  inviteCode?: string;
}

export interface AddWaitListResponse {
  success?: boolean;
  code?: string;
  message?: string;
}

export interface AddWaitListRequest {
  /** 用户名 */
  name: string;
  /** 项目名 */
  project?: string;
  /** 邮箱 */
  email: string;
  /** 钱包地址 */
  evmAddress?: string;
}

export interface AddWaitDeveloperListResponse {
  success?: boolean;
  code?: string;
  message?: string;
}

export interface AddWaitDeveloperListRequest {
  /** 项目名称 */
  projectName: string;
  /** 项目类别，可多选 */
  projectCategory: string[];
  /** 若项目类别选择 'Others'，请填写具体内容 */
  projectCategoryOther?: string;
  /** 简要描述您的项目、使命及其解决的问题 */
  projectDescription: string;
  /** 解释您的项目如何利用 T-Rex 并为生态系统带来什么价值 */
  ecosystemAlignment: string;
  /** 项目所处阶段 */
  projectStage: string;
  /** 项目网站 URL */
  projectWebsite: string;
  /** 项目 Twitter URL */
  projectTwitter?: string;
  /** 项目社区（Telegram 群组、Discord 等）URL */
  projectCommunity?: string;
  /** 主要联系人姓名 */
  primaryContactName: string;
  /** 联系人邮箱 */
  contactEmail: string;
  /** 联系人 Telegram 用户名（可选） */
  contactTelegram?: string;
  /** 寻求的支持类型，可多选 */
  supportType: string[];
  /** 若支持类型选择 'Other'，请填写具体内容 */
  supportTypeOther?: string;
  /** 简要概述计划如何使用申请的资金 */
  useOfFunds: string;
  /** 介绍您的核心团队及相关经验 */
  teamBackground: string;
  /** 上传项目推介材料或支持文档（文件上传或 URL） */
  supportingDocuments?: string;
  /** 其他需要我们了解的信息（可选） */
  additionalComments?: string;
}

export interface AddDeveloperWaitListUploadResponse {
  success?: boolean;
  code?: string;
  message?: string;
  obj?: AddDeveloperWaitListUploadResponseAllOfObj;
}

export interface AddDeveloperWaitListUploadResponseAllOfObj {
  /** 上传文件的名称 */
  fileName?: string;
  /** 上传文件的路径 */
  filePath?: string;
}

export interface AddWaitCreatorListResponse {
  success?: boolean;
  code?: string;
  message?: string;
}

export interface AddWaitCreatorListRequest {
  /** 你的姓名 */
  name: string;
  /** 联系邮箱 */
  contactEmail?: string;
  /** 联系 Telegram 用户名 */
  contactTelegram?: string;
  /** 联系 Discord 用户名 */
  contactDiscord?: string;
  /** 其他联系方式 */
  contactOther?: string;
  /** Instagram 账号 */
  socialsInstagram?: string;
  /** twitter 账号 */
  socialsTwitter?: string;
  /** youtube 账号 */
  socialsYoutube?: string;
  /** Tiktok 账号 */
  socialsTiktok?: string;
  /** Telegram 账号 */
  socialsTelegram?: string;
  /** 其他账号 */
  socialsOther?: string;
  /** 你创作的内容类型，可多选 */
  contentTypes?: string[];
  /** 若内容类型选择 'Others'，请填写具体内容 */
  contentTypesOther?: string;
  /** 你有兴趣加入 Trex 创作者计划的原因，可多选 */
  interestReasons?: string[];
  /** 若原因选择 'Others'，请填写具体内容 */
  interestReasonsOther?: string;
}

export interface ThirdAuthorizeInfo {
  /** 用户id */
  customerId?: string;
  /** 三方用户id */
  socialUserId?: string;
  /** 三方用户名 */
  socialHandleName?: string;
  /** 三方头像 */
  socialProfileImage?: string;
}

export interface ThirdAuthorizeResponse {
  success?: boolean;
  code?: string;
  message?: string;
  obj?: ThirdAuthorizeInfo;
}

export interface ThirdAuthorizeRequest {
  /** 授权平台 */
  platform: string;
  /** 授权code */
  code: string;
}

export interface AccessToken {
  /** 访问token */
  accessToken?: string;
  /** 刷新token */
  refreshToken?: string;
  /** 是否新用户 */
  isNewUser?: boolean;
  /** 是否新通行证 */
  isNewPassport?: boolean;
  /** 是否兑换成功 */
  isRedeemedSuccessfully?: boolean;
}

export interface AccessTokenResponse {
  success?: boolean;
  code?: string;
  message?: string;
  obj?: AccessToken;
}

export interface LoginRequest {
  /** 钱包地址 */
  walletAddress: string;
  /** thirdWeb签名 */
  signature: string;
  /** 验证码 */
  code?: string;
}

export interface LogoutResponse {
  success?: boolean;
  code?: string;
  message?: string;
}

export interface FaucetDripResponse {
  success?: boolean;
  code?: string;
  message?: string;
  obj?: FaucetDripResponseAllOfObj;
}

export interface FaucetDripResponseAllOfObj {
  /** 目标地址 */
  targetAddress?: string;
  /** 调用数据 */
  callData?: string;
  /** 金额 */
  amount?: string;
  /** 交易哈希 */
  txHash?: string;
}

export interface TaskConfig {
  /** 任务id，唯一标识 */
  taskId?: string;
  /** 任务标题 */
  title?: string;
  /** 任务的描述信息 */
  desc?: string;
  /** 任务详情链接 */
  url?: string;
  /** 授权地址 */
  connectUrl?: string;
  /**
   * 完成状态 0-未完成 1-已完成
   * @format int32
   */
  status?: number;
  /**
   * 0:不显示 1:go 2:verify
   * @format int32
   */
  btn?: number;
  /** map结构，key表示文案，例如connect now，value表示链接地址 */
  link?: Record<string, object>;
  /** 任务code */
  code?: string;
  /** 页面展示奖励金额 */
  reward?: number;
  /** 任务图标 */
  icon?: string;
}

export interface TaskListResponse {
  success?: boolean;
  code?: string;
  message?: string;
  obj?: TaskConfig[];
}

export interface RexyReward {
  /**
   * 奖励所属阶段
   * @format int32
   */
  stage?: number;
  /** 恐龙蛋编号，产生奖励后存在 */
  code?: string;
  point?: string;
  rewards?: RexyRewardItem[];
}

export interface RexyRewardItem {
  /**
   * 奖励所属阶段
   * @format int32
   */
  stage?: number;
  /** 恐龙蛋编号，产生奖励后存在 */
  code?: string;
  point?: string;
  /** 是否隐藏 */
  hidden?: boolean;
  status?: "EXPIRED" | "CLAIMED" | "UNCLAIMED";
}

export interface RexyRewardLastResponse {
  success?: boolean;
  code?: string;
  message?: string;
  obj?: RexyReward;
}

export interface RexyInfo {
  /** 用户id */
  customerId?: string;
  /** 头像 */
  avatar?: string;
  /**
   * 积分
   * @format int64
   */
  point?: number;
  rexy?: RexyInfoRexy;
}

export interface RexyInfoResponse {
  success?: boolean;
  code?: string;
  message?: string;
  obj?: RexyInfo;
}

export interface RexyInfoRexy {
  /** 恐龙id */
  id?: string;
  /** 恐龙名称 */
  name?: string;
  /**
   * 购物车积分
   * @format int32
   */
  basketPoint?: number;
  /**
   * 篮子积分上限
   * @format int32
   */
  limitPoint?: number;
  /**
   * 当前产生速率
   * @format int32
   */
  rate?: number;
  /** 头像 */
  avatar?: string;
}

export interface Rexys {
  /** 恐龙id */
  id?: string;
  /** 恐龙编号 */
  code?: string;
  /** 图片 */
  image?: string;
  /** 小图 */
  miniImage?: string;
  /** level */
  level?: string;
  /**
   * 生产速率
   * @format int32
   */
  rate?: number;
  /**
   * 篮子上限
   * @format int32
   */
  limit?: number;
  /**
   * 状态, 0:coming soon 1:lock 2:open
   * @format int32
   */
  status?: number;
  /** 是否拥有 */
  has?: boolean;
  /** 是否选中 */
  selected?: boolean;
}

export interface RexysResponse {
  success?: boolean;
  code?: string;
  message?: string;
  obj?: Rexys[];
}

/** nft conditions and progress */
export interface NftProgressVO {
  /** condition number */
  condition?: string;
  /** condition name */
  name?: string;
  /** condition type */
  type?: string;
  /** progress value */
  value?: string;
}

/** all nfts in series */
export interface NftVO {
  /**
   * minted Count
   * @format int64
   */
  mintedCount?: number;
  /** nft series logo */
  seriesLogo?: string;
  /** claimable id */
  claimableId?: string;
  /** nft type */
  type?: string;
  /**
   * nft tier
   * @format int32
   */
  tier?: number;
  /** price */
  price?: string;
  /** nft gateway logo */
  logo?: string;
  /**
   * reward
   * @format int32
   */
  reward?: number;
  /** show new tag */
  newTag?: boolean;
  /** nft complete process */
  process?: number;
  /** nft contract address */
  address?: string;
  /** nft token id */
  tokenId?: string;
  /** level */
  level?: string;
  /** nft series name */
  seriesName?: string;
  /**
   * total supply
   * @format int64
   */
  totalSupply?: number;
  /** nft condition max */
  maxCond?: number;
  /**
   * nft claimed time
   * @format int64
   */
  claimTime?: number;
  /** currency */
  token?: string;
  /** nft series type */
  series?: string;
  /** nft condition min */
  minCond?: number;
  /** nft name */
  name?: string;
  /** nft conditions and progress */
  progress?: NftProgressVO[];
  /** category */
  category?: string;
  /** nft desc */
  desc?: string;
  /** nft status(pending、claimable、claimed) */
  status?: string;
}

export interface PassportInfo {
  /** 用户ID */
  passportId?: string;
  /**
   * 创建时间
   * @format int64
   */
  created?: number;
  /** 用户名称 */
  userName?: string;
  /** 用户昵称或标识 */
  handleName?: string;
  /** 用户地址 */
  addresses?: string;
  /** 邮箱地址 */
  email?: string;
  /** KYC等级 */
  kycLevel?: string;
  /** 链id */
  chainId?: string;
  /** 登录方式 */
  authProvider?: string;
  /** 邀请码 */
  inviteCode?: string;
  /** 头像 */
  avatar?: string;
  badges?: NftVO[];
}

export interface PassportResponse {
  success?: boolean;
  code?: string;
  message?: string;
  obj?: PassportInfo;
}

export interface Notice {
  /** 通知 id */
  id?: string;
  /** 标题 */
  title?: string;
  /** 副标题 */
  subTitle?: string;
  /** 内容 */
  content?: string;
  /** 链接 */
  link?: string;
}

export interface NoticeResponse {
  success?: boolean;
  code?: string;
  message?: string;
  obj?: Notice[];
}

export interface NewsInfo {
  /** id */
  id?: string;
  /** 类型 Article、News、YouTube、DApp、XPost */
  type?: string;
  /** 名称 */
  name?: string;
  /** logo链接 */
  logo?: string;
  /** 标题 */
  title?: string;
  /** 子标题 */
  subTitle?: string;
  /** 图片 */
  image?: string;
  /** 外部链接 */
  link?: string;
  /** 标签 */
  category?: string[];
  /** 来源icon图标 */
  tag?: string;
  /**
   * 发布时间
   * @format int64
   */
  date?: number;
  /** 是否推荐置顶 */
  isRecommend?: boolean;
  /** 是否有奖励 */
  isReward?: boolean;
}

export interface NewsInfoResponse {
  success?: boolean;
  code?: string;
  message?: string;
  obj?: NewsInfo[];
}

export interface DiscoveryEvents {
  /** id */
  id?: string;
  /** 标题 */
  title?: string;
  /** 摘要 */
  summary?: string;
  /** 图片 */
  image?: string;
  /** 外部链接 */
  link?: string;
  /** 组织者 */
  organizer?: string;
  /** 地点 */
  location?: string;
  /**
   * 开始时间
   * @format int64
   */
  activityStartTime?: number;
  /**
   * 结束时间
   * @format int64
   */
  activityEndTime?: number;
  /** 剩余时间 */
  remainingTime?: string;
}

export interface DiscoveryEventsResponse {
  success?: boolean;
  code?: string;
  message?: string;
  obj?: DiscoveryEvents[];
}

export interface DiscoveryBlog {
  /** id */
  id?: string;
  /** 标题 */
  title?: string;
  /** 子标题，灰色小字 */
  type?: string;
  /** 摘要 */
  summary?: string;
  /** 正文内容链接 */
  link?: string;
  /** 正文内容 */
  content?: string;
  /** 图片 */
  image?: string;
  /** 是否推荐置顶 */
  isRecommend?: boolean;
  /**
   * 创建时间
   * @format int64
   */
  created?: number;
}

export interface DiscoveryBlogResponse {
  success?: boolean;
  code?: string;
  message?: string;
  obj?: DiscoveryBlog[];
}

export interface PrivacyAuthResponse {
  success?: boolean;
  code?: string;
  message?: string;
  obj?: PrivacyAuthVO;
}

export interface PrivacyAuthVO {
  /** X平台隐私授权状态 */
  privacyAuthX?: boolean;
  /** youtube平台的隐私授权状态 */
  privacyAuthYoutube?: boolean;
}

export interface InviteInfo {
  /** 用户id */
  customerId?: string;
  /** 用户注册时的钱包地址 */
  address?: string;
  /** 邀请码 */
  inviteCode?: string;
  /**
   * 邀请人数
   * @format int32
   */
  inviteCount?: number;
  /**
   * 邀请奖励
   * @format int32
   */
  inviteClaimedReward?: number;
  /**
   * 邀请未领取的奖励
   * @format int32
   */
  inviteUnClaimedReward?: number;
  /** 邀请规则 */
  inviteRule?: string;
}

export interface InviteInfoResponse {
  success?: boolean;
  code?: string;
  message?: string;
  obj?: InviteInfo;
}

export interface ThirdBindingsInfoInner {
  /** 第三方平台名称 */
  platform: string;
  /** 绑定状态 0-未绑定 1-已绑定 */
  status: string;
  /** 授权地址 */
  connectUrl: string;
  /** 社交账号名称 */
  socialHandleName: string;
  /** 社交账号头像URL */
  socialProfileImage: string;
}

export interface ThirdBindingsResponse {
  success?: boolean;
  code?: string;
  message?: string;
  obj?: ThirdBindingsInfoInner[];
}

export interface Challenge {
  /** 密钥 */
  text?: string;
}

export interface ChallengeResponse {
  success?: boolean;
  code?: string;
  message?: string;
  obj?: Challenge;
}

export type QueryParamsType = Record<string | number, any>;
export type ResponseFormat = keyof Omit<Body, "body" | "bodyUsed">;

export interface FullRequestParams extends Omit<RequestInit, "body"> {
  /** set parameter to `true` for call `securityWorker` for this request */
  secure?: boolean;
  /** request path */
  path: string;
  /** content type of request body */
  type?: ContentType;
  /** query params */
  query?: QueryParamsType;
  /** format of response (i.e. response.json() -> format: "json") */
  format?: ResponseFormat;
  /** request body */
  body?: unknown;
  /** base url */
  baseUrl?: string;
  /** request cancellation token */
  cancelToken?: CancelToken;
}

export type RequestParams = Omit<
  FullRequestParams,
  "body" | "method" | "query" | "path"
>;

export interface ApiConfig<SecurityDataType = unknown> {
  baseUrl?: string;
  baseApiParams?: Omit<RequestParams, "baseUrl" | "cancelToken" | "signal">;
  securityWorker?: (
    securityData: SecurityDataType | null,
  ) => Promise<RequestParams | void> | RequestParams | void;
  customFetch?: typeof fetch;
}

export interface HttpResponse<D extends unknown, E extends unknown = unknown>
  extends Response {
  data: D;
  error: E;
}

type CancelToken = Symbol | string | number;

export enum ContentType {
  Json = "application/json",
  JsonApi = "application/vnd.api+json",
  FormData = "multipart/form-data",
  UrlEncoded = "application/x-www-form-urlencoded",
  Text = "text/plain",
}

export class HttpClient<SecurityDataType = unknown> {
  public baseUrl: string = "https://api.trex.dev.dipbit.xyz";
  private securityData: SecurityDataType | null = null;
  private securityWorker?: ApiConfig<SecurityDataType>["securityWorker"];
  private abortControllers = new Map<CancelToken, AbortController>();
  private customFetch = (...fetchParams: Parameters<typeof fetch>) =>
    fetch(...fetchParams);

  private baseApiParams: RequestParams = {
    credentials: "same-origin",
    headers: {},
    redirect: "follow",
    referrerPolicy: "no-referrer",
  };

  constructor(apiConfig: ApiConfig<SecurityDataType> = {}) {
    Object.assign(this, apiConfig);
  }

  public setSecurityData = (data: SecurityDataType | null) => {
    this.securityData = data;
  };

  protected encodeQueryParam(key: string, value: any) {
    const encodedKey = encodeURIComponent(key);
    return `${encodedKey}=${encodeURIComponent(typeof value === "number" ? value : `${value}`)}`;
  }

  protected addQueryParam(query: QueryParamsType, key: string) {
    return this.encodeQueryParam(key, query[key]);
  }

  protected addArrayQueryParam(query: QueryParamsType, key: string) {
    const value = query[key];
    return value.map((v: any) => this.encodeQueryParam(key, v)).join("&");
  }

  protected toQueryString(rawQuery?: QueryParamsType): string {
    const query = rawQuery || {};
    const keys = Object.keys(query).filter(
      (key) => "undefined" !== typeof query[key],
    );
    return keys
      .map((key) =>
        Array.isArray(query[key])
          ? this.addArrayQueryParam(query, key)
          : this.addQueryParam(query, key),
      )
      .join("&");
  }

  protected addQueryParams(rawQuery?: QueryParamsType): string {
    const queryString = this.toQueryString(rawQuery);
    return queryString ? `?${queryString}` : "";
  }

  private contentFormatters: Record<ContentType, (input: any) => any> = {
    [ContentType.Json]: (input: any) =>
      input !== null && (typeof input === "object" || typeof input === "string")
        ? JSON.stringify(input)
        : input,
    [ContentType.JsonApi]: (input: any) =>
      input !== null && (typeof input === "object" || typeof input === "string")
        ? JSON.stringify(input)
        : input,
    [ContentType.Text]: (input: any) =>
      input !== null && typeof input !== "string"
        ? JSON.stringify(input)
        : input,
    [ContentType.FormData]: (input: any) =>
      Object.keys(input || {}).reduce((formData, key) => {
        const property = input[key];
        formData.append(
          key,
          property instanceof Blob
            ? property
            : typeof property === "object" && property !== null
              ? JSON.stringify(property)
              : `${property}`,
        );
        return formData;
      }, new FormData()),
    [ContentType.UrlEncoded]: (input: any) => this.toQueryString(input),
  };

  protected mergeRequestParams(
    params1: RequestParams,
    params2?: RequestParams,
  ): RequestParams {
    return {
      ...this.baseApiParams,
      ...params1,
      ...(params2 || {}),
      headers: {
        ...(this.baseApiParams.headers || {}),
        ...(params1.headers || {}),
        ...((params2 && params2.headers) || {}),
      },
    };
  }

  protected createAbortSignal = (
    cancelToken: CancelToken,
  ): AbortSignal | undefined => {
    if (this.abortControllers.has(cancelToken)) {
      const abortController = this.abortControllers.get(cancelToken);
      if (abortController) {
        return abortController.signal;
      }
      return void 0;
    }

    const abortController = new AbortController();
    this.abortControllers.set(cancelToken, abortController);
    return abortController.signal;
  };

  public abortRequest = (cancelToken: CancelToken) => {
    const abortController = this.abortControllers.get(cancelToken);

    if (abortController) {
      abortController.abort();
      this.abortControllers.delete(cancelToken);
    }
  };

  public request = async <T = any, E = any>({
    body,
    secure,
    path,
    type,
    query,
    format,
    baseUrl,
    cancelToken,
    ...params
  }: FullRequestParams): Promise<HttpResponse<T, E>> => {
    const secureParams =
      ((typeof secure === "boolean" ? secure : this.baseApiParams.secure) &&
        this.securityWorker &&
        (await this.securityWorker(this.securityData))) ||
      {};
    const requestParams = this.mergeRequestParams(params, secureParams);
    const queryString = query && this.toQueryString(query);
    const payloadFormatter = this.contentFormatters[type || ContentType.Json];
    const responseFormat = format || requestParams.format;

    return this.customFetch(
      `${baseUrl || this.baseUrl || ""}${path}${queryString ? `?${queryString}` : ""}`,
      {
        ...requestParams,
        headers: {
          ...(requestParams.headers || {}),
          ...(type && type !== ContentType.FormData
            ? { "Content-Type": type }
            : {}),
        },
        signal:
          (cancelToken
            ? this.createAbortSignal(cancelToken)
            : requestParams.signal) || null,
        body:
          typeof body === "undefined" || body === null
            ? null
            : payloadFormatter(body),
      },
    ).then(async (response) => {
      const r = response.clone() as HttpResponse<T, E>;
      r.data = null as unknown as T;
      r.error = null as unknown as E;

      const data = !responseFormat
        ? r
        : await response[responseFormat]()
            .then((data) => {
              if (r.ok) {
                r.data = data;
              } else {
                r.error = data;
              }
              return r;
            })
            .catch((e) => {
              r.error = e;
              return r;
            });

      if (cancelToken) {
        this.abortControllers.delete(cancelToken);
      }

      if (!response.ok) throw data;
      return data;
    });
  };
}

/**
 * @title trex api
 * @version 1.0
 * @baseUrl https://api.trex.dev.dipbit.xyz
 */
export class Api<
  SecurityDataType extends unknown,
> extends HttpClient<SecurityDataType> {
  v1 = {
    /**
     * @description 用户开始观看视频时创建新的会话，返回会话ID及相关奖励信息
     *
     * @tags Video
     * @name InitVideoSession
     * @summary 初始化视频观看会话
     * @request POST:/v1/video/session/init
     * @secure
     */
    initVideoSession: (
      data: VideoSessionInitRequest,
      params: RequestParams = {},
    ) =>
      this.request<VideoSessionInitResponse, VideoSessionInitResponse>({
        path: `/v1/video/session/init`,
        method: "POST",
        body: data,
        secure: true,
        type: ContentType.Json,
        format: "json",
        ...params,
      }),

    /**
     * @description 上报事件数据
     *
     * @tags Video
     * @name ReportEvents
     * @summary 上报事件数据
     * @request POST:/v1/video/events/report
     * @secure
     */
    reportEvents: (
      data: VideoEventsReportRequest,
      params: RequestParams = {},
    ) =>
      this.request<EventDataDetails, any>({
        path: `/v1/video/events/report`,
        method: "POST",
        body: data,
        secure: true,
        type: ContentType.Json,
        format: "json",
        ...params,
      }),

    /**
     * No description
     *
     * @tags Activity
     * @name TaskVerify
     * @summary 做任务
     * @request POST:/v1/task/verify
     * @secure
     */
    taskVerify: (data: TaskVerifyRequest, params: RequestParams = {}) =>
      this.request<TaskVerifyResponse, any>({
        path: `/v1/task/verify`,
        method: "POST",
        body: data,
        secure: true,
        type: ContentType.Json,
        format: "json",
        ...params,
      }),

    /**
     * No description
     *
     * @tags Activity
     * @name TaskSocialEvent
     * @summary 社交事件
     * @request POST:/v1/task/socialEvent
     * @secure
     */
    taskSocialEvent: (
      data: TaskSocialEventRequest,
      params: RequestParams = {},
    ) =>
      this.request<TaskSocialEventResponse, any>({
        path: `/v1/task/socialEvent`,
        method: "POST",
        body: data,
        secure: true,
        type: ContentType.Json,
        format: "json",
        ...params,
      }),

    /**
     * @description 恐龙收集奖励
     *
     * @tags Rexy
     * @name RexyRewardCollect
     * @summary 恐龙收集奖励
     * @request POST:/v1/rexys/reward/collect
     * @secure
     */
    rexyRewardCollect: (
      data: RexyRewardCollectRequest,
      params: RequestParams = {},
    ) =>
      this.request<RewardCollectResponse, any>({
        path: `/v1/rexys/reward/collect`,
        method: "POST",
        body: data,
        secure: true,
        type: ContentType.Json,
        format: "json",
        ...params,
      }),

    /**
     * @description 领取积分奖励
     *
     * @tags Rexy
     * @name RexyClaim
     * @summary 领取积分奖励
     * @request POST:/v1/rexys/claim
     * @secure
     */
    rexyClaim: (data: RexyClaimRequest, params: RequestParams = {}) =>
      this.request<ClaimResponse, any>({
        path: `/v1/rexys/claim`,
        method: "POST",
        body: data,
        secure: true,
        type: ContentType.Json,
        format: "json",
        ...params,
      }),

    /**
     * @description 生成交易业务id
     *
     * @tags Rexy
     * @name RexyClaimBuild
     * @summary 生成交易业务id
     * @request POST:/v1/rexys/claim/build/{basketType}
     * @secure
     */
    rexyClaimBuild: (
      basketType: string,
      query?: {
        /** 钱包地址 */
        address?: string;
      },
      params: RequestParams = {},
    ) =>
      this.request<ClaimBuildResponse, any>({
        path: `/v1/rexys/claim/build/${basketType}`,
        method: "POST",
        query: query,
        secure: true,
        format: "json",
        ...params,
      }),

    /**
     * @description 绑定钱包
     *
     * @tags Auth
     * @name BindWallet
     * @summary 绑定钱包
     * @request POST:/v1/passport/wallet/bind
     */
    bindWallet: (
      query?: {
        /** 用户钱包地址 */
        address?: string;
        /** 用户钱包签名 */
        signature?: string;
      },
      params: RequestParams = {},
    ) =>
      this.request<BindWalletResponse, any>({
        path: `/v1/passport/wallet/bind`,
        method: "POST",
        query: query,
        format: "json",
        ...params,
      }),

    /**
     * @description 保存用户handleName信息
     *
     * @tags Passport
     * @name SetHandleName
     * @summary 保存用户handleName信息
     * @request POST:/v1/passport/setHandleName
     */
    setHandleName: (
      query: {
        /** handleName */
        handleName: string;
      },
      params: RequestParams = {},
    ) =>
      this.request<SetHandleNameResponse, any>({
        path: `/v1/passport/setHandleName`,
        method: "POST",
        query: query,
        format: "json",
        ...params,
      }),

    /**
     * @description Upload a social media post
     *
     * @tags Customer
     * @name PlatformSocialUpload
     * @summary /customers/platform/social/upload
     * @request POST:/v1/customers/social/upload
     */
    platformSocialUpload: (
      data: SocialUploadRequest,
      params: RequestParams = {},
    ) =>
      this.request<SocialUploadResponse, any>({
        path: `/v1/customers/social/upload`,
        method: "POST",
        body: data,
        type: ContentType.Json,
        format: "json",
        ...params,
      }),

    /**
     * @description 更新用户授权隐私状态
     *
     * @tags Customer
     * @name ReversePrivacyAuth
     * @summary 更新用户授权隐私状态
     * @request POST:/v1/customers/privacy/reverseAuth
     */
    reversePrivacyAuth: (
      data: ReversePrivacyAuth,
      params: RequestParams = {},
    ) =>
      this.request<ReservePrivacyAuthResponse, any>({
        path: `/v1/customers/privacy/reverseAuth`,
        method: "POST",
        body: data,
        type: ContentType.Json,
        format: "json",
        ...params,
      }),

    /**
     * @description 邀请绑定
     *
     * @tags Customer
     * @name BindInvite
     * @summary 邀请绑定
     * @request POST:/v1/customers/invites/bind
     * @secure
     */
    bindInvite: (data: InviteBindRequest, params: RequestParams = {}) =>
      this.request<InviteBindResponse, any>({
        path: `/v1/customers/invites/bind`,
        method: "POST",
        body: data,
        secure: true,
        type: ContentType.Json,
        format: "json",
        ...params,
      }),

    /**
     * @description join the waitList from officialWebsite
     *
     * @tags Customer
     * @name AddWaitList
     * @summary /customers/addWaitList
     * @request POST:/v1/customers/addWaitList
     */
    addWaitList: (data: AddWaitListRequest, params: RequestParams = {}) =>
      this.request<AddWaitListResponse, any>({
        path: `/v1/customers/addWaitList`,
        method: "POST",
        body: data,
        type: ContentType.Json,
        format: "json",
        ...params,
      }),

    /**
     * @description join the wait developer List
     *
     * @tags Customer
     * @name AddWaitDeveloperList
     * @summary /customers/addWaitDeveloperList
     * @request POST:/v1/customers/addDeveloperWaitList
     */
    addWaitDeveloperList: (
      data: AddWaitDeveloperListRequest,
      params: RequestParams = {},
    ) =>
      this.request<AddWaitDeveloperListResponse, any>({
        path: `/v1/customers/addDeveloperWaitList`,
        method: "POST",
        body: data,
        type: ContentType.Json,
        format: "json",
        ...params,
      }),

    /**
     * @description 用于上传文件，返回文件名称和文件路径
     *
     * @tags Customer
     * @name AddWaitListUpload
     * @summary 上传文件
     * @request POST:/v1/customers/addDeveloperWaitList/upload
     */
    addWaitListUpload: (
      data: {
        /**
         * 需要上传的文件
         * @format binary
         */
        file?: File;
      },
      params: RequestParams = {},
    ) =>
      this.request<AddDeveloperWaitListUploadResponse, any>({
        path: `/v1/customers/addDeveloperWaitList/upload`,
        method: "POST",
        body: data,
        type: ContentType.FormData,
        format: "json",
        ...params,
      }),

    /**
     * @description join the wait creator List
     *
     * @tags Customer
     * @name AddWaitCreatorList
     * @summary /customers/addWaitCreatorList
     * @request POST:/v1/customers/addCreateWaitList
     */
    addWaitCreatorList: (
      data: AddWaitCreatorListRequest,
      params: RequestParams = {},
    ) =>
      this.request<AddWaitCreatorListResponse, any>({
        path: `/v1/customers/addCreateWaitList`,
        method: "POST",
        body: data,
        type: ContentType.Json,
        format: "json",
        ...params,
      }),

    /**
     * @description third platform authorize
     *
     * @tags Auth
     * @name ThirdAuthorize
     * @summary /customer/auth/third/authorize
     * @request POST:/v1/auth/third/authorize
     * @secure
     */
    thirdAuthorize: (data: ThirdAuthorizeRequest, params: RequestParams = {}) =>
      this.request<ThirdAuthorizeResponse, any>({
        path: `/v1/auth/third/authorize`,
        method: "POST",
        body: data,
        secure: true,
        type: ContentType.Json,
        format: "json",
        ...params,
      }),

    /**
     * @description 刷新
     *
     * @tags Auth
     * @name RefreshAccessToken
     * @summary 刷新accessToken
     * @request POST:/v1/auth/refresh
     */
    refreshAccessToken: (
      query?: {
        /** accessToken */
        accessToken?: string;
        /** refreshToken */
        refreshToken?: string;
      },
      params: RequestParams = {},
    ) =>
      this.request<AccessTokenResponse, any>({
        path: `/v1/auth/refresh`,
        method: "POST",
        query: query,
        format: "json",
        ...params,
      }),

    /**
     * @description 登录
     *
     * @tags Auth
     * @name QrAuthLogin
     * @summary 登录
     * @request POST:/v1/auth/qr/login
     */
    qrAuthLogin: (data: LoginRequest, params: RequestParams = {}) =>
      this.request<AccessTokenResponse, any>({
        path: `/v1/auth/qr/login`,
        method: "POST",
        body: data,
        type: ContentType.Json,
        format: "json",
        ...params,
      }),

    /**
     * @description 登出
     *
     * @tags Auth
     * @name Logout
     * @summary 登出
     * @request POST:/v1/auth/logout
     * @secure
     */
    logout: (params: RequestParams = {}) =>
      this.request<LogoutResponse, any>({
        path: `/v1/auth/logout`,
        method: "POST",
        secure: true,
        format: "json",
        ...params,
      }),

    /**
     * @description 登录
     *
     * @tags Auth
     * @name AuthLogin
     * @summary 登录
     * @request POST:/v1/auth/login
     */
    authLogin: (data: LoginRequest, params: RequestParams = {}) =>
      this.request<AccessTokenResponse, any>({
        path: `/v1/auth/login`,
        method: "POST",
        body: data,
        type: ContentType.Json,
        format: "json",
        ...params,
      }),

    /**
     * @description 水龙头领水
     *
     * @tags Tx
     * @name FaucetDrip
     * @summary 水龙头领水
     * @request GET:/v1/tx/faucet
     */
    faucetDrip: (
      query: {
        /** 领取水的钱包地址 */
        address: string;
      },
      params: RequestParams = {},
    ) =>
      this.request<FaucetDripResponse, any>({
        path: `/v1/tx/faucet`,
        method: "GET",
        query: query,
        format: "json",
        ...params,
      }),

    /**
     * No description
     *
     * @tags Activity
     * @name TaskList
     * @summary 获取任务列表
     * @request GET:/v1/task/list
     */
    taskList: (params: RequestParams = {}) =>
      this.request<TaskListResponse, any>({
        path: `/v1/task/list`,
        method: "GET",
        format: "json",
        ...params,
      }),

    /**
     * @description 查询最新恐龙蛋
     *
     * @tags Rexy
     * @name RexyRewardLast
     * @summary 查询最新恐龙蛋
     * @request GET:/v1/rexys/reward/last
     * @secure
     */
    rexyRewardLast: (
      query: {
        /** 平台，可选值：X 或 YouTube */
        platform: string;
        /** 内容id */
        content_id?: string;
      },
      params: RequestParams = {},
    ) =>
      this.request<RexyRewardLastResponse, any>({
        path: `/v1/rexys/reward/last`,
        method: "GET",
        query: query,
        secure: true,
        format: "json",
        ...params,
      }),

    /**
     * @description 查询当前用户宠物信息
     *
     * @tags Rexy
     * @name Rexy
     * @summary 查询当前用户宠物信息
     * @request GET:/v1/rexys/me
     * @secure
     */
    rexy: (params: RequestParams = {}) =>
      this.request<RexyInfoResponse, any>({
        path: `/v1/rexys/me`,
        method: "GET",
        secure: true,
        format: "json",
        ...params,
      }),

    /**
     * @description 查询恐龙列表
     *
     * @tags Rexy
     * @name Rexys
     * @summary 查询恐龙列表
     * @request GET:/v1/rexys/avatar
     * @secure
     */
    rexys: (params: RequestParams = {}) =>
      this.request<RexysResponse, any>({
        path: `/v1/rexys/avatar`,
        method: "GET",
        secure: true,
        format: "json",
        ...params,
      }),

    /**
     * @description 返回用户的passport基本信息，包括customerId、created时间和handleName
     *
     * @tags Passport
     * @name GetPassportInfo
     * @summary 查询用户passport信息
     * @request GET:/v1/passport/me
     */
    getPassportInfo: (params: RequestParams = {}) =>
      this.request<PassportResponse, any>({
        path: `/v1/passport/me`,
        method: "GET",
        format: "json",
        ...params,
      }),

    /**
     * @description 查询未读消息通知列表
     *
     * @tags Notice
     * @name GetNotices
     * @summary 查询未读消息通知列表
     * @request GET:/v1/notice
     * @secure
     */
    getNotices: (
      query?: {
        /**
         * 最后一次拉取通知的时间
         * @format int64
         * @default 0
         */
        lastFetchNotifyTime?: number;
      },
      params: RequestParams = {},
    ) =>
      this.request<NoticeResponse, any>({
        path: `/v1/notice`,
        method: "GET",
        query: query,
        secure: true,
        format: "json",
        ...params,
      }),

    /**
     * @description 查询新闻列表
     *
     * @tags News
     * @name News
     * @summary 查询新闻列表
     * @request GET:/v1/news
     * @secure
     */
    news: (
      query?: {
        /**
         * 偏移量
         * @format int64
         * @default 0
         */
        offset?: number;
        /**
         * 查询数量
         * @format int64
         * @default 10
         */
        limit?: number;
      },
      params: RequestParams = {},
    ) =>
      this.request<NewsInfoResponse, any>({
        path: `/v1/news`,
        method: "GET",
        query: query,
        secure: true,
        format: "json",
        ...params,
      }),

    /**
     * @description discovery events
     *
     * @tags News
     * @name DiscoveryEvents
     * @summary discovery events
     * @request GET:/v1/news/discovery/events
     */
    discoveryEvents: (
      query?: {
        /**
         * 偏移量
         * @format int64
         * @default 0
         */
        offset?: number;
        /**
         * 查询数量
         * @format int64
         * @default 10
         */
        limit?: number;
      },
      params: RequestParams = {},
    ) =>
      this.request<DiscoveryEventsResponse, any>({
        path: `/v1/news/discovery/events`,
        method: "GET",
        query: query,
        format: "json",
        ...params,
      }),

    /**
     * @description discovery blog
     *
     * @tags News
     * @name DiscoveryBlog
     * @summary discovery blog
     * @request GET:/v1/news/dicovery/blog
     */
    discoveryBlog: (
      query?: {
        /**
         * 偏移量
         * @format int64
         * @default 0
         */
        offset?: number;
        /**
         * 查询数量
         * @format int64
         * @default 10
         */
        limit?: number;
      },
      params: RequestParams = {},
    ) =>
      this.request<DiscoveryBlogResponse, any>({
        path: `/v1/news/dicovery/blog`,
        method: "GET",
        query: query,
        format: "json",
        ...params,
      }),

    /**
     * @description 查询新闻列表banner
     *
     * @tags News
     * @name Banner
     * @summary 查询新闻banner
     * @request GET:/v1/news/banner
     * @secure
     */
    banner: (params: RequestParams = {}) =>
      this.request<NewsInfoResponse, any>({
        path: `/v1/news/banner`,
        method: "GET",
        secure: true,
        format: "json",
        ...params,
      }),

    /**
     * @description 查询用户是否同意授权隐私协议
     *
     * @tags Customer
     * @name PrivacyAuth
     * @summary 查询用户是否同意授权隐私协议
     * @request GET:/v1/customers/privacy/auth
     */
    privacyAuth: (params: RequestParams = {}) =>
      this.request<PrivacyAuthResponse, any>({
        path: `/v1/customers/privacy/auth`,
        method: "GET",
        format: "json",
        ...params,
      }),

    /**
     * @description 查询当前用户邀请信息
     *
     * @tags Customer
     * @name Invite
     * @summary 查询当前用户邀请信息
     * @request GET:/v1/customers/invites/me
     * @secure
     */
    invite: (params: RequestParams = {}) =>
      this.request<InviteInfoResponse, any>({
        path: `/v1/customers/invites/me`,
        method: "GET",
        secure: true,
        format: "json",
        ...params,
      }),

    /**
     * @description third platform bind lists
     *
     * @tags Auth
     * @name ThirdBindings
     * @summary /customer/auth/third/bindings
     * @request GET:/v1/auth/third/bindings
     * @secure
     */
    thirdBindings: (params: RequestParams = {}) =>
      this.request<ThirdBindingsResponse, any>({
        path: `/v1/auth/third/bindings`,
        method: "GET",
        secure: true,
        format: "json",
        ...params,
      }),

    /**
     * @description 获取一个密钥
     *
     * @tags Auth
     * @name Challenge
     * @summary 获取一个密钥
     * @request GET:/v1/auth/challenge
     * @secure
     */
    challenge: (
      query: {
        /** 地址 */
        address: string;
        /**
         * wallet or social
         * @default "social"
         */
        type?: string;
      },
      params: RequestParams = {},
    ) =>
      this.request<ChallengeResponse, any>({
        path: `/v1/auth/challenge`,
        method: "GET",
        query: query,
        secure: true,
        format: "json",
        ...params,
      }),
  };
}
